require 'rubygems'
require 'hpricot'

module HomeHelper

	def get_chinese_wday num
	  {"0" => "星期天", "1" => "星期一", "2" => "星期二", "3" => "星期三", "4" => "星期四", "5" => "星期五", "6" => "星期六"}["#{num}"] 
	end

  def get_img_src news
    return "home/p13_01.png"
    # TO_DO
    doc = Hpricot(news.body)
    if doc
      first_image = (doc/"img").first
      if first_image
        return first_image.get_attribute("src")
      end
    end
  end

  def check_image_src news
    result = false
    doc = Hpricot(news.body)
    if doc
      first_image = (doc/"img").first
      if first_image
        result = true
      end
    end
    return result
  end

  def get_body_text news
    text = ""
    doc = Hpricot(news.body)
    if doc
       text = (doc/"//*/text()").to_s
    end
    text = news.body unless text.present?
    text
  end

end